﻿using com.yoozoo.gta.Gameplay.PVE;
using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(ResObjectCacheManager))]
public class ResObjectCacheManagerEditor : Editor
{
    private ResObjectCacheManager manager;
    void OnEnable()
    {
        manager = target as ResObjectCacheManager;
    }

    public override void OnInspectorGUI()
    {
        var paths = manager.GetAllResPath();
        int assetCount = paths.Count;
        int totalReference = 0;
        GUILayout.BeginVertical();
        foreach (var path in paths)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label(path);
            var resReference = manager.GetResReference(path);
            var resLoadTimes = manager.GetResLoadTimes(path);
            totalReference += resReference;
            GUILayout.Label(resReference.ToString());
            GUILayout.Label(resLoadTimes.ToString());
            GUILayout.EndHorizontal();
        }

        GUILayout.BeginHorizontal();
        GUILayout.Label($"Total assets: {assetCount}, total references: {totalReference}");
        GUILayout.EndHorizontal();

        GUILayout.EndVertical();
    }
}
